#include <Inventor/SoDB.h>
#include <Inventor/nodes/SoCube.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSphere.h>
#include <Inventor/sensors/SoNodeSensor.h>

#include <tchar.h>

void RemoveCube();  // Defined later...

int _tmain(int argc, _TCHAR* argv[])
{
   SoDB::init();

   // Create some objects and give them names:
   SoSeparator *root = new SoSeparator;
   root->ref();
   root->setName("Root");

   SoCube *myCube = new SoCube;
   root->addChild(myCube);
   myCube->setName("MyCube");
   SoSphere *mySphere = new SoSphere;
   root->addChild(mySphere);
   mySphere->setName("MySphere");

   RemoveCube();
}

void
RemoveCube()
{
   // Remove the cube named 'MyCube' from the separator named
   // 'Root'.  In a real application, isOfType() would probably
   // be used to make sure the nodes are of the correct type
   // before doing the cast.

   SoSeparator *myRoot;
   myRoot = (SoSeparator *)SoNode::getByName("Root");

   SoCube *myCube;
   myCube = (SoCube *)SoNode::getByName("MyCube");

   myRoot->removeChild(myCube);
}
